package com.zlm.Date;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author 13026
 */
public class SimpleDateFormatDemo {
    public static void main(String[] args) throws ParseException {
        /*
        * 1.把时间变成喜欢的格式
        * 2.把字符串表示的时间转成Date
        * */
        SimpleDateFormat sdf = new SimpleDateFormat();
        Date d = new Date(0L);
        String s = sdf.format(d);
        System.out.println(s);

        SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String s2 = sdf2.format(d);
        System.out.println(s2);

        String formatStr = "2024-02-02 22:22:22";
        Date date = sdf2.parse(formatStr);
        System.out.println(date.getTime());
    }
}
